//
//  InformationViewController.m
//  iStore
//
//  Created by Geek on 15/4/22.
//  Copyright (c) 2015年 mirrtalk. All rights reserved.
//


#import "InformationViewController.h"
#import "RequestEngine.h"
#import "UserModel.h"
@interface InformationViewController ()

{
    NSDictionary * dic;
    
}

@end

@implementation InformationViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = @"个人资料";
    
   NSString *userId = [[NSUserDefaults standardUserDefaults] objectForKey:kUserId];
    
    dic = @{@"userID":userId};

    [self activityStart];
    [RequestEngine RequestEngineWithDic:dic URL:@"user/getUserInfo" completed:^(NSString *errorcode,NSDictionary *resultDict) {
        NSLog(@"%@",errorcode);
        [self activityStop];
        if ([errorcode isEqualToString:@"0"]) {
            UserModel *user=[UserModel sharedUserModel];
            [user resetUserModel:resultDict];
            [self refresh:user];
        }        

    }];
    
    
}
- (void)refresh:(UserModel*)user
{
    if (user.userName.length) {
        [self.userName setText:user.userName];
    }
    if (user.email.length) {
        [self.userEmail setText:user.email];
    }
    if (user.phone.length) {
        [self.userPhonoe setText:user.phone];
    }
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
 #pragma mark - Navigation
 
 // In a storyboard-based application, you will often want to do a little preparation before navigation
 - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
 // Get the new view controller using [segue destinationViewController].
 // Pass the selected object to the new view controller.
 }
 */

@end
